package com.tao.picture.ui.girl.data.local

import androidx.room.*
import com.tao.picture.ui.girl.data.entity.Girl

@Dao
interface ImageDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(images: List<Girl>)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(image: Girl)

    /**
     * 返回更新成功的个数
     */
    @Update
    suspend fun update(images: List<Girl>): Int

    @Update
    suspend fun update(image: Girl): Int

    @Delete
    suspend fun delete(images: List<Girl>)

    @Delete
    suspend fun delete(image: Girl)

    @Query("DELETE FROM girl")
    suspend fun clean()

    @Query("SELECT * FROM girl ORDER BY views DESC")
    suspend fun getImage() : List<Girl>

    @Query("SELECT * FROM girl WHERE id = :id")
    suspend fun getImage(id: String): Girl

//    @Query("SELECT * FROM girl WHERE id = :id")
//    fun getImage(id: String): LiveData<Girl>
//
//    @Query("SELECT * FROM girl WHERE id = :id")
//    suspend fun getImage(id: String): Flow<Girl>
}